Imports System.Data.OracleClient
Imports system.Data.OleDb

Public Class NVDataAccess

    Dim objSqlConnection As System.Data.OleDb.OleDbConnection
    Dim booEstaConectado As Boolean

    Public Sub New()
        Try
            objSqlConnection = New System.Data.OleDb.OleDbConnection
            objSqlConnection.ConnectionString = "Provider=OraOLEDB.Oracle.1;Data Source=XE;User ID=labadm;Password=labadm;Unicode=True"
            objSqlConnection.Open()
            booEstaConectado = True
        Catch ex As OleDb.OleDbException
            booEstaConectado = False
            Throw New Exception("No se pudo abrir la base de datos")
        Catch ex As Exception
            booEstaConectado = False
            Throw New Exception("No se pudo abrir la base de datos")
        End Try
    End Sub

    Public Function setDataAccess(ByVal strSql As String) As Integer

        If booEstaConectado = False Then
            Throw New Exception("No se pudo abrir la base de datos")
            Return 1
        End If

        Try
            Dim objCommand As OleDb.OleDbCommand = New OleDb.OleDbCommand
            objCommand.Connection = objSqlConnection
            objCommand.CommandText = strSql
            objCommand.ExecuteReader()
        Catch ex As Exception
            Throw ex
        End Try

    End Function

    Public Function CloseConnection() As Boolean
        Try
            objSqlConnection.Close()
            Return True
        Catch ex As Exception
            Throw New Exception("No se pude cerrar la clase")
            Return False
        End Try
    End Function
End Class
